<!DOCTYPE html>
<html>

  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="Cache-Control" content="no-siteapp" />

    <title>Introduction of xmake v2.2.5 new features</title>
    <meta name="description" content="This version took more than four months to refactor and improve the package dependency management. The official repository added common packages such as mysq...">

    
    <meta name="keywords" content="xmake,lua,C/C++,package,conan,homebrew,vcpkg,tboox" /> 

    <!-- qq oauth -->
    <meta property="qc:admins" content="5211601217706727767255" />

    <!--icon -->
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
    <link rel="icon" sizes="192x192" href="/static/img/nice-highres.png" />
	<link rel="apple-touch-icon-precomposed" href="/static/img/apple-touch-icon-57x57-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/static/img/apple-touch-icon-72x72-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/static/img/apple-touch-icon-114x114-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/static/img/apple-touch-icon-144x144-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="180x180" href="/static/img/retinahd_icon.png" />
	<meta name="msapplication-TileImage" content="/static/img/retinahd_icon.png" />
	
    <link rel="stylesheet" href=" /css/fontawesome/css/font-awesome.min.css ">
    <link rel="stylesheet" href=" /css/main.css ">
    <link rel="canonical" href="https://tboox.org/2019/04/01/xmake-v2.2.5-new-features/">
    <link rel="alternate" type="application/rss+xml" title="TBOOX Open Source Project" href="https://tboox.org/feed.xml ">
    <link rel="alternate" hreflang="en" href="https://tboox.org/" />
    <link rel="alternate" hreflang="zh-Hans" href="https://tboox.org/cn/" />




    <script type="text/javascript">
    function isPC(){    
        var userAgentInfo = navigator.userAgent;  
        var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");    
        var flag = true;    
        for (var v = 0; v < Agents.length; v++) {    
            if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }    
        }    
        return flag;    
    }
    </script>

<!-- baidu ads -->



    <!-- baidu ads -->

</head>


  <body>

    <header id="top">
    <div class="wrapper">
        <a href="/" class="brand">TBOOX</a>
        <button id="headerMenu" class="menu"><i class="fa fa-bars"></i></button>
        <nav id="headerNav">
            <ul>
                <li>
                    
                    <a href="/cn?lang=0">
                    
                        <i class="fa fa-home"></i>中文
                    </a>
                </li>

                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/project/">
                            
                        
                            <i class="fa fa-bookmark"></i>Projects
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/archive/">
                            
                        
                            <i class="fa fa-archive"></i>Archives
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/category/">
                            
                        
                            <i class="fa fa-th-list"></i>Categories
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/tag/">
                            
                        
                            <i class="fa fa-tags"></i>Tags
                        </a>
                    </li>
                    
                    
                    
                
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/docs/">
                            
                        
                            <i class="fa fa-book"></i>Documents
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="https://xmake.io/#/about/contact" target="_blank" >
                            
                        
                            <i class="fa fa-forumbee"></i>Community
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/donation/">
                            
                        
                            <i class="fa fa-heart"></i>Donate
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/about/">
                            
                        
                            <i class="fa fa-user"></i>About
                        </a>
                    </li>
                    
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                     
                     
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            </ul>
        </nav>
    </div>
</header>



        <div class="page clearfix" post>
    <div class="left">
        <h1>Introduction of xmake v2.2.5 new features</h1>
        <div class="label">

            <div class="label-card">
                <i class="fa fa-calendar"></i>2019-04-01
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
            


<!-- <span class="point">•</span> -->
<span class="categories">
  <i class="fa fa-th-list"></i>
  
    
        <a href="/category/#xmake" title="Category: xmake" rel="category">xmake</a>
    
  

  <!-- <span class="point">•</span> -->
</span>


            </div>

            <div class="label-card">
            
<!-- <span class="point">•</span> -->
<span class="pageTag">
  <i class="fa fa-tags"></i>
  
    
        <!--a href="/tag/#xmake" title="Tag: xmake" rel="tag">xmake</a-->
        <a href="/tag/#xmake" title="Tag: xmake" rel="tag">xmake</a>&nbsp;
    
        <!--a href="/tag/#lua" title="Tag: lua" rel="tag">lua</a-->
        <a href="/tag/#lua" title="Tag: lua" rel="tag">lua</a>&nbsp;
    
        <!--a href="/tag/#C%2FC%2B%2B" title="Tag: C/C++" rel="tag">C/C++</a-->
        <a href="/tag/#C/C++" title="Tag: C/C++" rel="tag">C/C++</a>&nbsp;
    
        <!--a href="/tag/#package" title="Tag: package" rel="tag">package</a-->
        <a href="/tag/#package" title="Tag: package" rel="tag">package</a>&nbsp;
    
        <!--a href="/tag/#conan" title="Tag: conan" rel="tag">conan</a-->
        <a href="/tag/#conan" title="Tag: conan" rel="tag">conan</a>&nbsp;
    
        <!--a href="/tag/#homebrew" title="Tag: homebrew" rel="tag">homebrew</a-->
        <a href="/tag/#homebrew" title="Tag: homebrew" rel="tag">homebrew</a>&nbsp;
    
        <!--a href="/tag/#vcpkg" title="Tag: vcpkg" rel="tag">vcpkg</a-->
        <a href="/tag/#vcpkg" title="Tag: vcpkg" rel="tag">vcpkg</a>
    
  

</span>

            </div>

        </div>
        <hr>
        <article itemscope itemtype="http://schema.org/BlogPosting">
        <p>This version took more than four months to refactor and improve the package dependency management. 
The official repository added common packages such as mysql and ffmpeg, and added a lot of features.</p>

<ul>
  <li><a href="https://github.com/xmake-io/xmake">Github</a></li>
  <li><a href="https://xmake.io/#/home">Documents</a></li>
</ul>

<h2 id="builtin-package-manager">Builtin package manager</h2>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"libuv master"</span><span class="p">,</span> <span class="s2">"ffmpeg"</span><span class="p">,</span> <span class="s2">"zlib 1.20.*"</span><span class="p">)</span><span class="err">`</span>
</code></pre>
</div>

<p>xmake will find and install packages from the official package repository (<a href="https://github.com/xmake-io/xmake-repo">xmake-repo</a>).</p>

<h2 id="support-third-party-package-manager">Support third-party package manager</h2>

<p>xmake adds built-in support for third-party package managers, explicitly specifying packages in other package managers through package namespaces, 
and it currently supports <code class="highlighter-rouge">conan::</code>, <code class="highlighter-rouge">brew::</code> and <code class="highlighter-rouge">vcpkg::</code> packages.</p>

<h4 id="install-packages-from-homebrewlinuxbrew">Install packages from homebrew/linuxbrew</h4>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"brew::zlib"</span><span class="p">,</span> <span class="p">{</span><span class="n">alias</span> <span class="o">=</span> <span class="s2">"zlib"</span><span class="p">}})</span>
<span class="n">add_requires</span><span class="p">(</span><span class="s2">"brew::pcre2/libpcre2-8"</span><span class="p">,</span> <span class="p">{</span><span class="n">alias</span> <span class="o">=</span> <span class="s2">"pcre2"</span><span class="p">}})</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">)</span> 
    <span class="n">add_packages</span><span class="p">(</span><span class="s2">"pcre2"</span><span class="p">,</span> <span class="s2">"zlib"</span><span class="p">)</span>
</code></pre>
</div>

<h4 id="install-packages-from-vcpkg">Install packages from vcpkg</h4>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"vcpkg::zlib"</span><span class="p">,</span> <span class="s2">"vcpkg::pcre2"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">)</span> 
    <span class="n">add_packages</span><span class="p">(</span><span class="s2">"vcpkg::zlib"</span><span class="p">,</span> <span class="s2">"vcpkg::pcre2"</span><span class="p">)</span>
</code></pre>
</div>

<h4 id="install-packages-from-conan">Install packages from conan</h4>

<p>The new version implements the conan generator to integrate the package information in the conan. 
It is also very convenient to use in xmake, and can pass all the configuration parameters of the conan package.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"conan::zlib/1.2.11@conan/stable"</span><span class="p">,</span> <span class="p">{</span><span class="n">alias</span> <span class="o">=</span> <span class="s2">"zlib"</span><span class="p">,</span> <span class="n">debug</span> <span class="o">=</span> <span class="kc">true</span><span class="p">})</span>
<span class="n">add_requires</span><span class="p">(</span><span class="s2">"conan::OpenSSL/1.0.2n@conan/stable"</span><span class="p">,</span> <span class="p">{</span><span class="n">alias</span> <span class="o">=</span> <span class="s2">"openssl"</span><span class="p">,</span> <span class="n">configs</span> <span class="o">=</span> <span class="p">{</span><span class="n">options</span> <span class="o">=</span> <span class="s2">"OpenSSL:shared=True"</span><span class="p">}})</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">)</span> 
    <span class="n">add_packages</span><span class="p">(</span><span class="s2">"openssl"</span><span class="p">,</span> <span class="s2">"zlib"</span><span class="p">)</span>
</code></pre>
</div>

<p>After executing xmake to compile:</p>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code>ruki:test_package ruki<span class="nv">$ </span>xmake
checking <span class="k">for </span>the architecture ... x86_64
checking <span class="k">for </span>the Xcode directory ... /Applications/Xcode.app
checking <span class="k">for </span>the SDK version of Xcode ... 10.14
note: try installing these packages <span class="o">(</span>pass -y to skip confirm<span class="o">)</span>?
  -&gt; conan::zlib/1.2.11@conan/stable  <span class="o">(</span>debug<span class="o">)</span>
  -&gt; conan::OpenSSL/1.0.2n@conan/stable  
please input: y <span class="o">(</span>y/n<span class="o">)</span>

  <span class="o">=</span>&gt; installing conan::zlib/1.2.11@conan/stable .. ok
  <span class="o">=</span>&gt; installing conan::OpenSSL/1.0.2n@conan/stable .. ok

<span class="o">[</span>  0%]: ccache compiling.release src/main.c
<span class="o">[</span>100%]: linking.release <span class="nb">test</span>
</code></pre>
</div>

<h2 id="built-in-dependency-package-lookup-support">Built-in dependency package lookup support</h2>

<p>The previous version provided <code class="highlighter-rouge">lib.detect.find_package</code> to look up the dependent library, but this needs to be imported before it can be used, and only one package can be found at a time, which is cumbersome:</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">)</span>
    <span class="n">on_load</span><span class="p">(</span><span class="k">function</span> <span class="p">(</span><span class="n">target</span><span class="p">)</span>
        <span class="n">import</span><span class="p">(</span><span class="s2">"lib.detect.find_package"</span><span class="p">)</span>
        <span class="n">target</span><span class="p">:</span><span class="n">add</span><span class="p">(</span><span class="n">find_package</span><span class="p">(</span><span class="s2">"openssl"</span><span class="p">))</span>
        <span class="n">target</span><span class="p">:</span><span class="n">add</span><span class="p">(</span><span class="n">find_package</span><span class="p">(</span><span class="s2">"zlib"</span><span class="p">))</span>
    <span class="k">end</span><span class="p">)</span>
</code></pre>
</div>

<p>The new version of the <code class="highlighter-rouge">find_packages</code> interface, the <code class="highlighter-rouge">lib.detect.find_package</code> is further encapsulated to improve ease of use:</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">)</span>
    <span class="n">on_load</span><span class="p">(</span><span class="k">function</span> <span class="p">(</span><span class="n">target</span><span class="p">)</span>
        <span class="n">target</span><span class="p">:</span><span class="n">add</span><span class="p">(</span><span class="n">find_packages</span><span class="p">(</span><span class="s2">"openssl"</span><span class="p">,</span> <span class="s2">"zlib"</span><span class="p">))</span>
    <span class="k">end</span><span class="p">)</span>
</code></pre>
</div>

<p>It also supports searching from a specified third-party package manager:</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">find_packages</span><span class="p">(</span><span class="s2">"conan::OpenSSL/1.0.2n@conan/stable"</span><span class="p">,</span> <span class="s2">"brew::zlib"</span><span class="p">)</span>
</code></pre>
</div>

<h2 id="install-packages-with-parameter-configuration">Install packages with parameter configuration</h2>

<p>The new version has a large-scale refactoring and upgrade of the built-in package management, and has better support for the parameter configurable compilation and installation dependencies. 
We can define some compilation and installation configuration parameters in the package repository to customize the installation package.</p>

<p>For example, let’s take the pcre2 package as an example:</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code>
<span class="n">package</span><span class="p">(</span><span class="s2">"pcre2"</span><span class="p">)</span>

    <span class="n">set_homepage</span><span class="p">(</span><span class="s2">"https://www.pcre.org/"</span><span class="p">)</span>
    <span class="n">set_description</span><span class="p">(</span><span class="s2">"A Perl Compatible Regular Expressions Library"</span><span class="p">)</span>

    <span class="n">set_urls</span><span class="p">(</span><span class="s2">"https://ftp.pcre.org/pub/pcre/pcre2-$(version).zip"</span><span class="p">,</span>
             <span class="s2">"ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-$(version).zip"</span><span class="p">)</span>

    <span class="n">add_versions</span><span class="p">(</span><span class="s2">"10.23"</span><span class="p">,</span> <span class="s2">"6301a525a8a7e63a5fac0c2fbfa0374d3eb133e511d886771e097e427707094a"</span><span class="p">)</span>
    <span class="n">add_versions</span><span class="p">(</span><span class="s2">"10.30"</span><span class="p">,</span> <span class="s2">"3677ce17854fffa68fce6b66442858f48f0de1f537f18439e4bd2771f8b4c7fb"</span><span class="p">)</span>
    <span class="n">add_versions</span><span class="p">(</span><span class="s2">"10.31"</span><span class="p">,</span> <span class="s2">"b4b40695a5347a770407d492c1749e35ba3970ca03fe83eb2c35d44343a5a444"</span><span class="p">)</span>

    <span class="n">add_configs</span><span class="p">(</span><span class="s2">"shared"</span><span class="p">,</span> <span class="p">{</span><span class="n">description</span> <span class="o">=</span> <span class="s2">"Enable shared library."</span><span class="p">,</span> <span class="n">default</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span> <span class="nb">type</span> <span class="o">=</span> <span class="s2">"boolean"</span><span class="p">})</span>
    <span class="n">add_configs</span><span class="p">(</span><span class="s2">"jit"</span><span class="p">,</span> <span class="p">{</span><span class="n">description</span> <span class="o">=</span> <span class="s2">"Enable jit."</span><span class="p">,</span> <span class="n">default</span> <span class="o">=</span> <span class="kc">true</span><span class="p">,</span> <span class="nb">type</span> <span class="o">=</span> <span class="s2">"boolean"</span><span class="p">})</span>
    <span class="n">add_configs</span><span class="p">(</span><span class="s2">"bitwidth"</span><span class="p">,</span> <span class="p">{</span><span class="n">description</span> <span class="o">=</span> <span class="s2">"Set the code unit width."</span><span class="p">,</span> <span class="n">default</span> <span class="o">=</span> <span class="s2">"8"</span><span class="p">,</span> <span class="n">values</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"8"</span><span class="p">,</span> <span class="s2">"16"</span><span class="p">,</span> <span class="s2">"32"</span><span class="p">}})</span>
</code></pre>
</div>

<p>In the above, we define three conditional configuration parameters through <code class="highlighter-rouge">add_configs</code>, so that when the user uses the pcre2 library, you can customize whether you need to enable the jit version, bit width version, etc., for example:</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"pcre2"</span><span class="p">,</span> <span class="p">{</span><span class="n">configs</span> <span class="o">=</span> <span class="p">{</span><span class="n">jit</span> <span class="o">=</span> <span class="kc">true</span><span class="p">,</span> <span class="n">bitwidth</span> <span class="o">=</span> <span class="mi">8</span><span class="p">}})</span>
</code></pre>
</div>

<p>Moreover, the configuration parameters are strongly constrained. If the value passed is incorrect, an error will be reported to avoid passing invalid parameters. 
As with the bitwidth parameter configuration, it can only be restricted to <code class="highlighter-rouge">values = {"8", "16". "32"}</code> inside takes the value.</p>

<p>So, how do users know which configuration parameters are currently supported by our package? It’s very simple. We can quickly view all the information of the pcre2 package by using the following command:</p>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>xmake require --info pcre2
</code></pre>
</div>

<p>The output is as follows:</p>

<div class="highlighter-rouge"><pre class="highlight"><code>The package info of project:
    require(pcre2): 
      -&gt; description: A Perl Compatible Regular Expressions Library
      -&gt; version: 10.31
      -&gt; urls:
         -&gt; https://ftp.pcre.org/pub/pcre/pcre2-10.31.zip
            -&gt; b4b40695a5347a770407d492c1749e35ba3970ca03fe83eb2c35d44343a5a444
         -&gt; ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-10.31.zip
            -&gt; b4b40695a5347a770407d492c1749e35ba3970ca03fe83eb2c35d44343a5a444
      -&gt; repo: local-repo /Users/ruki/projects/personal/xmake-repo/ 
      -&gt; cachedir: /Users/ruki/.xmake/cache/packages/p/pcre2/10.31
      -&gt; installdir: /Users/ruki/.xmake/packages/p/pcre2/10.31/23b52ca1c6c8634f5f935903c9e7ea0e
      -&gt; fetchinfo: 10.31, system, optional
          -&gt; linkdirs: /usr/local/Cellar/pcre2/10.32/lib
          -&gt; defines: PCRE2_CODE_UNIT_WIDTH=8
          -&gt; links: pcre2-8
          -&gt; version: 10.32
          -&gt; includedirs: /usr/local/Cellar/pcre2/10.32/include
      -&gt; platforms: linux, macosx
      -&gt; requires:
         -&gt; plat: macosx
         -&gt; arch: x86_64
         -&gt; configs:
            -&gt; vs_runtime: MT
            -&gt; shared: false
            -&gt; jit: true
            -&gt; bitwidth: 8
            -&gt; debug: false
      -&gt; configs:
         -&gt; shared: Enable shared library. (default: false)
         -&gt; jit: Enable jit. (default: true)
         -&gt; bitwidth: Set the code unit width. (default: 8)
            -&gt; values: {"8","16","32"}
      -&gt; configs (builtin):
         -&gt; debug: Enable debug symbols. (default: false)
         -&gt; cflags: Set the C compiler flags.
         -&gt; cxflags: Set the C/C++ compiler flags.
         -&gt; cxxflags: Set the C++ compiler flags.
         -&gt; asflags: Set the assembler flags.
         -&gt; vs_runtime: Set vs compiler runtime. (default: MT)
            -&gt; values: {"MT","MD"}
</code></pre>
</div>

<p>Among them, the <code class="highlighter-rouge">configs:</code> part inside is the parameter description and value range that can be provided at present, and <code class="highlighter-rouge">configs (builtin):</code> is some built-in configuration parameters of xmake, and the user can also directly configure and use.</p>

<p>For example, the most commonly used debug mode package:</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"pcre2"</span><span class="p">,</span> <span class="p">{</span><span class="n">configs</span> <span class="o">=</span> <span class="p">{</span><span class="n">debug</span> <span class="o">=</span> <span class="kc">true</span><span class="p">}})</span>
</code></pre>
</div>

<p>Since this is too common, xmake provides more convenient configuration support:</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"pcre2"</span><span class="p">,</span> <span class="p">{</span><span class="n">debug</span> <span class="o">=</span> <span class="kc">true</span><span class="p">})</span>
</code></pre>
</div>

<p>In addition, the content of <code class="highlighter-rouge">requires:</code> is the configuration state of the current dependent package, which is convenient for the user to view which mode package is currently used.</p>

<h2 id="preprocessing-template-configuration-file">Preprocessing template configuration file</h2>

<p>xmake provides three new interface APIs for adding pre-compiled configuration files before compiling instead of <a href="https://xmake.io/#/zh/manual?id=targetset_config_header">set_config_header</a>.</p>

<ul>
  <li><code class="highlighter-rouge">add_configfiles</code></li>
  <li><code class="highlighter-rouge">set_configdir</code></li>
  <li><code class="highlighter-rouge">set_configvar</code></li>
</ul>

<p>Among them <code class="highlighter-rouge">add_configfiles</code> is equivalent to the <code class="highlighter-rouge">configure_file</code> interface in cmake, xmake refers to its api design, and has extended support on it to provide more flexibility.</p>

<p>This interface is more general than the previous <code class="highlighter-rouge">set_config_header</code>, not only for automatic generation and preprocessing of config.h, but also for various file types, while <code class="highlighter-rouge">set_config_header</code> is only used for processing header files and does not support templates. Variable substitution.</p>

<p>Let’s start with a simple example:</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">)</span>
    <span class="n">set_configdir</span><span class="p">(</span><span class="s2">"$(buildir)/config"</span><span class="p">)</span>
    <span class="n">add_configfiles</span><span class="p">(</span><span class="s2">"src/config.h.in"</span><span class="p">)</span>
</code></pre>
</div>

<p>The above settings will automatically configure the <code class="highlighter-rouge">config.h.in</code> header file template before compiling. 
After preprocessing, it will generate the output to the specified <code class="highlighter-rouge">build/config/config.h</code>.</p>

<p>One of the most important features of this interface is that it can be preprocessed and replaced with some of the template variables in the preprocessing, for example:</p>

<p>config.h.in</p>

<div class="highlighter-rouge"><pre class="highlight"><code>#define VAR1 "${VAR1}"
#define VAR2 "${VAR2}"
#define HELLO "${HELLO}"
</code></pre>
</div>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">set_configvar</span><span class="p">(</span><span class="s2">"VAR1"</span><span class="p">,</span> <span class="s2">"1"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"main.c"</span><span class="p">)</span>

    <span class="n">set_configvar</span><span class="p">(</span><span class="s2">"VAR2"</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
    <span class="n">add_configfiles</span><span class="p">(</span><span class="s2">"config.h.in"</span><span class="p">,</span> <span class="p">{</span><span class="n">variables</span> <span class="o">=</span> <span class="p">{</span><span class="n">hello</span> <span class="o">=</span> <span class="s2">"xmake"</span><span class="p">}})</span>
    <span class="n">add_configfiles</span><span class="p">(</span><span class="s2">"*.man"</span><span class="p">,</span> <span class="p">{</span><span class="n">copyonly</span> <span class="o">=</span> <span class="kc">true</span><span class="p">})</span>
</code></pre>
</div>

<p>Set the template variable via the <a href="https://xmake.io/#/zh/manual?id=targetset_configvar">set_configvar</a> interface, wrapped in a variable set in <code class="highlighter-rouge"><span class="p">{</span><span class="err">variables</span><span class="w"> </span><span class="err">=</span><span class="w"> </span><span class="err">{xxx</span><span class="w"> </span><span class="err">=</span><span class="w"> </span><span class="nt">""</span><span class="err">}}</span></code> .</p>

<p>The preprocessed file <code class="highlighter-rouge">config.h</code> is:</p>

<div class="highlighter-rouge"><pre class="highlight"><code>#define VAR1 "1"
#define VAR2 "2"
#define HELLO "xmake"
</code></pre>
</div>

<p>The <code class="highlighter-rouge"><span class="p">{</span><span class="err">copyonly</span><span class="w"> </span><span class="err">=</span><span class="w"> </span><span class="err">true</span><span class="p">}</span></code> setting will force <code class="highlighter-rouge">*.man</code> to be treated as a normal file, copying files only during the preprocessing stage, and not replacing variables.</p>

<p>The default template variable matching mode is <code class="highlighter-rouge">${var}</code>, of course we can also set other matching modes, for example, to <code class="highlighter-rouge">@var@</code> matching rules:</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">add_configfiles</span><span class="p">(</span><span class="s2">"config.h.in"</span><span class="p">,</span> <span class="p">{</span><span class="n">pattern</span> <span class="o">=</span> <span class="s2">"@(.-)@"</span><span class="p">})</span>
</code></pre>
</div>

<p>We also have some built-in variables that can be replaced with default variables even if they are not set through this interface:</p>

<div class="highlighter-rouge"><pre class="highlight"><code>${VERSION} -&gt; 1.6.3
${VERSION_MAJOR} -&gt; 1
${VERSION_MINOR} -&gt; 6
${VERSION_ALTER} -&gt; 3
${VERSION_BUILD} -&gt; set_version("1.6.3", {build = "%Y%m%d%H%M"}) -&gt; 201902031421
${PLAT} and ${plat} -&gt; MACOS and macosx
${ARCH} and ${arch} -&gt; ARM and arm
${MODE} and ${mode} -&gt; DEBUG/RELEASE and debug/release
${DEBUG} and ${debug} -&gt; 1 or 0
${OS} and ${os} -&gt; IOS or ios
</code></pre>
</div>

<p>For example:</p>

<p>config.h.in</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="cp">#define CONFIG_VERSION "${VERSION}"
#define CONFIG_VERSION_MAJOR ${VERSION_MAJOR}
#define CONFIG_VERSION_MINOR ${VERSION_MINOR}
#define CONFIG_VERSION_ALTER ${VERSION_ALTER}
#define CONFIG_VERSION_BUILD ${VERSION_BUILD}
</span></code></pre>
</div>

<p>config.h</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="cp">#define CONFIG_VERSION "1.6.3"
#define CONFIG_VERSION_MAJOR 1
#define CONFIG_VERSION_MINOR 6
#define CONFIG_VERSION_ALTER 3
#define CONFIG_VERSION_BUILD 201902031401
</span></code></pre>
</div>

<p>We can also perform some variable state control processing on the <code class="highlighter-rouge">#define</code> definition:</p>

<p>config.h.in</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="err">$</span><span class="p">{</span><span class="n">define</span> <span class="n">FOO_ENABLE</span><span class="p">}</span>
</code></pre>
</div>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">set_configvar</span><span class="p">(</span><span class="s2">"FOO_ENABLE"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="c1">-- or pass true</span>
<span class="n">set_configvar</span><span class="p">(</span><span class="s2">"FOO_STRING"</span><span class="p">,</span> <span class="s2">"foo"</span><span class="p">)</span>
</code></pre>
</div>

<p>After setting the above variable, <code class="highlighter-rouge">${define xxx}</code> will be replaced with:</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="cp">#define FOO_ENABLE 1
#define FOO_STRING "foo"
</span></code></pre>
</div>

<p>Or (when set to 0 disable)</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="cm">/* #undef FOO_ENABLE */</span>
<span class="cm">/* #undef FOO_STRING */</span>
</code></pre>
</div>

<p>This method is very useful for some automatic detection generation config.h, such as with the option to do automatic detection:</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">option</span><span class="p">(</span><span class="s2">"foo"</span><span class="p">)</span>
    <span class="n">set_default</span><span class="p">(</span><span class="kc">true</span><span class="p">)</span>
    <span class="n">set_description</span><span class="p">(</span><span class="s2">"Enable Foo"</span><span class="p">)</span>
    <span class="n">set_configvar</span><span class="p">(</span><span class="s2">"FOO_ENABLE"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="c1">-- or pass true to enable the FOO_ENABLE variable</span>
    <span class="n">set_configvar</span><span class="p">(</span><span class="s2">"FOO_STRING"</span><span class="p">,</span> <span class="s2">"foo"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">add_configfiles</span><span class="p">(</span><span class="s2">"config.h.in"</span><span class="p">)</span>

    <span class="c1">-- If the foo option is enabled -&gt; Add FOO_ENABLE and FOO_STRING definitions</span>
    <span class="n">add_options</span><span class="p">(</span><span class="s2">"foo"</span><span class="p">)</span> 
</code></pre>
</div>

<p>config.h.in</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="err">$</span><span class="p">{</span><span class="n">define</span> <span class="n">FOO_ENABLE</span><span class="p">}</span>
<span class="err">$</span><span class="p">{</span><span class="n">define</span> <span class="n">FOO_STRING</span><span class="p">}</span>
</code></pre>
</div>

<p>config.h</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="cp">#define FOO_ENABLE 1
#define FOO_STRING "foo"
</span></code></pre>
</div>

<p>Regarding the option option detection, and the automatic generation of config.h, there are some helper functions, you can look at it: https://github.com/xmake-io/xmake/issues/342</p>

<p>In addition to <code class="highlighter-rouge">#define</code>, if you want to do state switching for other non-#define xxx<code class="highlighter-rouge">s, you can use the </code>${default xxx 0}` mode to set the default value, for example:</p>

<div class="highlighter-rouge"><pre class="highlight"><code>HAVE_SSE2 equ ${default VAR_HAVE_SSE2 0}
</code></pre>
</div>

<p>After <code class="highlighter-rouge">set_configvar("HAVE_SSE2", 1)</code> is enabled, it becomes <code class="highlighter-rouge">HAVE_SSE2 equ 1</code>. If no variable is set, the default value is used: <code class="highlighter-rouge">HAVE_SSE2 equ 0</code></p>

<p>For a detailed description of this, see: <a href="https://github.com/xmake-io/xmake/issues/320">https://github.com/xmake-io/xmake/issues/320</a></p>

<h2 id="more-convenient-feature-detection">More convenient feature detection</h2>

<p>We can use <code class="highlighter-rouge">add_configfiles</code> with option detection to detect whether some header files, interface functions, types, and compiler features exist. If they exist, they are automatically written to config.h, for example:</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">option</span><span class="p">(</span><span class="s2">"foo"</span><span class="p">)</span>
    <span class="n">set_default</span><span class="p">(</span><span class="kc">true</span><span class="p">)</span>
    <span class="n">set_description</span><span class="p">(</span><span class="s2">"Has pthread library"</span><span class="p">)</span>
    <span class="n">add_cincludes</span><span class="p">(</span><span class="s2">"pthread.h"</span><span class="p">)</span>
    <span class="n">add_cfuncs</span><span class="p">(</span><span class="s2">"pthread_create"</span><span class="p">)</span>
    <span class="n">add_links</span><span class="p">(</span><span class="s2">"pthread"</span><span class="p">)</span>
    <span class="n">set_configvar</span><span class="p">(</span><span class="s2">"HAS_PTHREAD"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> 

<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">add_configfiles</span><span class="p">(</span><span class="s2">"config.h.in"</span><span class="p">)</span>
    <span class="n">add_options</span><span class="p">(</span><span class="s2">"pthread"</span><span class="p">)</span> 
</code></pre>
</div>

<p>config.h.in</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="err">$</span><span class="p">{</span><span class="n">define</span> <span class="n">HAS_PTHREAD</span><span class="p">}</span>
</code></pre>
</div>

<p>config.h</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="cp">#define HAS_PTHREAD 1
</span></code></pre>
</div>

<p>In the above configuration, we check whether the interface in pthread.h and the link library exist by option. If the pthread library can be used normally, then <code class="highlighter-rouge">HAS_PTHREAD</code> is automatically defined in config.h, and related links are added to the test target.</p>

<p>The above option can support a variety of detection, but the configuration is a bit more complicated and cumbersome, in order to make xmake.lua more simple and intuitive, 
for some common detection, we improved <a href="https://xmake.io/#/zh/manual?id=includes">includes</a> interface to provide some built-in packaged auxiliary interface functions to quickly implement the above option detection and write config.h.</p>

<p>The above code can be simplified to:</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">includes</span><span class="p">(</span><span class="s2">"check_cfuncs.lua"</span><span class="p">)</span>
<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">add_configfiles</span><span class="p">(</span><span class="s2">"config.h.in"</span><span class="p">)</span>
    <span class="n">configvar_check_cfuncs</span><span class="p">(</span><span class="s2">"HAS_PTHREAD"</span><span class="p">,</span> <span class="s2">"pthread_create"</span><span class="p">,</span> <span class="p">{</span><span class="n">includes</span> <span class="o">=</span> <span class="s2">"pthread.h"</span><span class="p">,</span> <span class="n">links</span> <span class="o">=</span> <span class="s2">"pthread"</span><span class="p">})</span>
</code></pre>
</div>

<p>In addition to <code class="highlighter-rouge">configvar_check_cfuncs</code>, we also have the <code class="highlighter-rouge">check_cfuncs</code> function. Only the test results are appended directly at compile time and are no longer written to the configfiles file.</p>

<p>Let us look at a comprehensive example:</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">includes</span><span class="p">(</span><span class="s2">"check_links.lua"</span><span class="p">)</span>
<span class="n">includes</span><span class="p">(</span><span class="s2">"check_ctypes.lua"</span><span class="p">)</span>
<span class="n">includes</span><span class="p">(</span><span class="s2">"check_cfuncs.lua"</span><span class="p">)</span>
<span class="n">includes</span><span class="p">(</span><span class="s2">"check_features.lua"</span><span class="p">)</span>
<span class="n">includes</span><span class="p">(</span><span class="s2">"check_csnippets.lua"</span><span class="p">)</span>
<span class="n">includes</span><span class="p">(</span><span class="s2">"check_cincludes.lua"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"*.c"</span><span class="p">)</span>
    <span class="n">add_configfiles</span><span class="p">(</span><span class="s2">"config.h.in"</span><span class="p">)</span>

    <span class="n">configvar_check_ctypes</span><span class="p">(</span><span class="s2">"HAS_WCHAR"</span><span class="p">,</span> <span class="s2">"wchar_t"</span><span class="p">)</span>
    <span class="n">configvar_check_cincludes</span><span class="p">(</span><span class="s2">"HAS_STRING_H"</span><span class="p">,</span> <span class="s2">"string.h"</span><span class="p">)</span>
    <span class="n">configvar_check_cincludes</span><span class="p">(</span><span class="s2">"HAS_STRING_AND_STDIO_H"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"string.h"</span><span class="p">,</span> <span class="s2">"stdio.h"</span><span class="p">})</span>
    <span class="n">configvar_check_ctypes</span><span class="p">(</span><span class="s2">"HAS_WCHAR_AND_FLOAT"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"wchar_t"</span><span class="p">,</span> <span class="s2">"float"</span><span class="p">})</span>
    <span class="n">configvar_check_links</span><span class="p">(</span><span class="s2">"HAS_PTHREAD"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"pthread"</span><span class="p">,</span> <span class="s2">"m"</span><span class="p">,</span> <span class="s2">"dl"</span><span class="p">})</span>
    <span class="n">configvar_check_csnippets</span><span class="p">(</span><span class="s2">"HAS_STATIC_ASSERT"</span><span class="p">,</span> <span class="s2">"_Static_assert(1, \"</span><span class="err">\</span><span class="s2">");"</span><span class="p">)</span>
    <span class="n">configvar_check_cfuncs</span><span class="p">(</span><span class="s2">"HAS_SETJMP"</span><span class="p">,</span> <span class="s2">"setjmp"</span><span class="p">,</span> <span class="p">{</span><span class="n">includes</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"signal.h"</span><span class="p">,</span> <span class="s2">"setjmp.h"</span><span class="p">}})</span>
    <span class="n">configvar_check_features</span><span class="p">(</span><span class="s2">"HAS_CONSTEXPR"</span><span class="p">,</span> <span class="s2">"cxx_constexpr"</span><span class="p">)</span>
    <span class="n">configvar_check_features</span><span class="p">(</span><span class="s2">"HAS_CONSEXPR_AND_STATIC_ASSERT"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"cxx_constexpr"</span><span class="p">,</span> <span class="s2">"c_static_assert"</span><span class="p">},</span> <span class="p">{</span><span class="n">languages</span> <span class="o">=</span> <span class="s2">"c++11"</span><span class="p">})</span>
</code></pre>
</div>

<p>config.h.in</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="err">$</span><span class="p">{</span><span class="n">define</span> <span class="n">HAS_STRING_H</span><span class="p">}</span>
<span class="err">$</span><span class="p">{</span><span class="n">define</span> <span class="n">HAS_STRING_AND_STDIO_H</span><span class="p">}</span>
<span class="err">$</span><span class="p">{</span><span class="n">define</span> <span class="n">HAS_WCHAR</span><span class="p">}</span>
<span class="err">$</span><span class="p">{</span><span class="n">define</span> <span class="n">HAS_WCHAR_AND_FLOAT</span><span class="p">}</span>
<span class="err">$</span><span class="p">{</span><span class="n">define</span> <span class="n">HAS_PTHREAD</span><span class="p">}</span>
<span class="err">$</span><span class="p">{</span><span class="n">define</span> <span class="n">HAS_STATIC_ASSERT</span><span class="p">}</span>
<span class="err">$</span><span class="p">{</span><span class="n">define</span> <span class="n">HAS_SETJMP</span><span class="p">}</span>
<span class="err">$</span><span class="p">{</span><span class="n">define</span> <span class="n">HAS_CONSTEXPR</span><span class="p">}</span>
<span class="err">$</span><span class="p">{</span><span class="n">define</span> <span class="n">HAS_CONSEXPR_AND_STATIC_ASSERT</span><span class="p">}</span>
</code></pre>
</div>

<p>config.h</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="cm">/* #undef HAS_STRING_H */</span>
<span class="cp">#define HAS_STRING_AND_STDIO_H 1
</span><span class="cm">/* #undef HAS_WCHAR */</span>
<span class="cm">/* #undef HAS_WCHAR_AND_FLOAT */</span>
<span class="cp">#define HAS_PTHREAD 1
#define HAS_STATIC_ASSERT 1
#define HAS_SETJMP 1
</span><span class="cm">/* #undef HAS_CONSTEXPR */</span>
<span class="cp">#define HAS_CONSEXPR_AND_STATIC_ASSERT 1
</span></code></pre>
</div>

<p>As you can see, xmake also provides other helper functions for detecting: c/c++ types, c/c++ code snippets, c/c++ function interfaces, link libraries, header files, and even c/c++ compiler features. Support strength, etc.</p>

<p>For a more complete description of this, you can read: <a href="https://github.com/xmake-io/xmake/issues/342">https://github.com/xmake-io/xmake/issues/342</a></p>

<h2 id="configuring-a-custom-installation-file">Configuring a custom installation file</h2>

<p>For the <code class="highlighter-rouge">xmake install/uninstall</code> command, xmake adds the <code class="highlighter-rouge">add_installfiles</code> interface to set up some installation files. Compared to <code class="highlighter-rouge">on_install</code>, this interface is more convenient and simple to use, and basically meets most installation requirements.</p>

<p>For example, we can specify to install various types of files to the installation directory:</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">add_installfiles</span><span class="p">(</span><span class="s2">"src/*.h"</span><span class="p">)</span>
    <span class="n">add_installfiles</span><span class="p">(</span><span class="s2">"doc/*.md"</span><span class="p">)</span>
</code></pre>
</div>

<p>By default on Linux and other systems, we will install to <code class="highlighter-rouge">/usr/local/*.h, /usr/local/*.md</code>, but we can also specify to install to a specific subdirectory:</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">add_installfiles</span><span class="p">(</span><span class="s2">"src/*.h"</span><span class="p">,</span> <span class="p">{</span><span class="n">prefixdir</span> <span class="o">=</span> <span class="s2">"include"</span><span class="p">})</span>
    <span class="n">add_installfiles</span><span class="p">(</span><span class="s2">"doc/*.md"</span><span class="p">,</span> <span class="p">{</span><span class="n">prefixdir</span> <span class="o">=</span> <span class="s2">"share/doc"</span><span class="p">})</span>
</code></pre>
</div>

<p>The above settings, we will install to <code class="highlighter-rouge">/usr/local/include/*.h, /usr/local/share/doc/*.md</code></p>

<p>We can also install by subdirectory in the source file by <code class="highlighter-rouge">()</code>, for example:</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">add_installfiles</span><span class="p">(</span><span class="s2">"src/(tbox/*.h)"</span><span class="p">,</span> <span class="p">{</span><span class="n">prefixdir</span> <span class="o">=</span> <span class="s2">"include"</span><span class="p">})</span>
    <span class="n">add_installfiles</span><span class="p">(</span><span class="s2">"doc/(tbox/*.md)"</span><span class="p">,</span> <span class="p">{</span><span class="n">prefixdir</span> <span class="o">=</span> <span class="s2">"share/doc"</span><span class="p">})</span>
</code></pre>
</div>

<p>We extract the <code class="highlighter-rouge">tbox/*.h</code> subdirectory structure from the files in <code class="highlighter-rouge">src/tbox/*.h</code> and install it: <code class="highlighter-rouge">/usr/local/include/tbox/*.h, /usr/local /share/doc/tbox/*.md</code></p>

<p>Of course, users can also use the <a href="https://xmake.io/#/zh/manual?id=targetset_installdir">set_installdir</a> interface.</p>

<p>For a detailed description of this interface, see: <a href="https://github.com/xmake-io/xmake/issues/318">#318</a></p>

<h2 id="export-cmakeliststxt-file">Export CMakelists.txt file</h2>

<p>The new version extends the <code class="highlighter-rouge">xmake project</code> project generation plugin and adds export support for the CMakelists.txt file. Users who are comfortable with xmake can quickly export CMakelists.txt to cmake.
And some tools that support cmake, such as CLion, are used as follows:</p>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>xmake project -k cmakelists
</code></pre>
</div>

<p>The corresponding CMakelists.txt file can be generated in the current project directory.</p>

<h2 id="more-new-feature-improvements">More new feature improvements</h2>

<p>Please see: <a href="https://github.com/xmake-io/xmake/releases/tag/v2.2.5">https://github.com/xmake-io/xmake/releases/tag/v2.2.5</a></p>

        </article>
        <hr>

        <!-- baidu ads -->
        

        
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
                    
                    <h2 id="chinese">中文</h2>
                    <ul>
                    
                    <li class="relatedPost">
                        <a href="/cn/2019/04/01/xmake-v2.2.5-new-features/">xmake v2.2.5新特性详解
                        
                        </a>
                    </li>
                    
                    
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
        
            </ul>
        

        
        
            
            
            
                
                    
                        
                        <h2 id="similar_posts">Similar Posts</h2>
                        <ul>
                        
                        <li class="relatedPost">
                            <a href="/2021/12/17/xmake-update-v2.6.2/">Xmake v2.6.2 released, Support building Linux kernel driver module
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/2021/12/03/xmake-update-v2.6.1/">xmake v2.6.1 released, Switch to Lua5.4 runtime, Support Rust and C++ mixed compilation
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/2021/10/30/xmake-update-v2.5.9/">xmake v2.5.9 released, Improve C++20 Modules and support Nim, Keil MDK and Unity Build
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/2021/10/08/xmake-update-v2.5.8/">xmake v2.5.8 is released, Support Pascal/Swig program and Lua53 runtime
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/2021/08/29/xmake-update-v2.5.7/">xmake v2.5.7 released, Use lockfile to freeze package dependencies and Vala/Metal language support
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
        
            </ul>
        

        <div class="post-recent">
    <div class="pre">

        

        

        
        
        

        

        

        
        
        <p><strong>Prev Post</strong> <a href="/2019/03/29/xmake-update-v2.2.5/">xmake v2.2.5, More complete package dependency management</a></p>
        
    </div>

    <div class="nex">

        

        

        
        
        

        

        

        
        
        <p><strong>Next Post</strong> <a href="/2019/05/26/xmake-update-v2.2.6/">xmake v2.2.6 released, Support Qt/Adnroid application</a></p>
        
    </div>
</div>


        <h2 id="comments">Comments</h2>
        






<div id="gitalk-container"></div>
<link rel="stylesheet" href="/css/gitalk.css">
<script src="/js/gitalk.min.js"></script>

<script>
const gitalk = new Gitalk({
  clientID: '73946dc1d9e2276ad0da',
  clientSecret: '12a3cb94361ba3ebc6ecb68cf80d592bfaa8106d',
  repo: 'tboox.github.io',
  owner: 'waruqi',
  admin: ['waruqi'],
  id: location.pathname,      
  language: 'en',
  distractionFreeMode: false  
})

gitalk.render('gitalk-container')
</script>





    </div>
    <button class="anchor"><i class="fa fa-anchor"></i></button>
    <div class="right">
        <div class="wrap">


            <!-- codefund ads -->
            

            <!-- Content -->
            <div class="side content">
                <div>
                    Content
                </div>
                <ul id="content-side" class="content-ul">
                    <li><a href="#chinese">中文</a></li>
                    <li><a href="#similar_posts">Similar Posts</a></li>
                    <li><a href="#comments">Comments</a></li>
                </ul>
            </div>

            <!-- baidu ads -->
            

            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    Links
                </div>
                <ul class="content-ul">
                  <li><a href="http://github.com/waruqi/tbox">tbox</a></li>
                  <li><a href="http://www.xmake.io">xmake</a></li>
                  <li><a href="https://github.com/waruqi">github</a></li>
                </ul>
            </div> 

            <!-- google ads -->
            

            <!-- baidu ads -->
            

            <!-- chitika ads -->
            
        </div>
    </div>

    <!-- baidu ads -->
    
</div>
<script>
/**
 * target _blank
 */
(function() {
    var aTags = document.querySelectorAll('article a:not([id])')
    for (var i = 0; i < aTags.length; i++) {
        aTags[i].setAttribute('target', '_blank')
    }
}());
</script>
<script src="/js/pageContent.js " charset="utf-8"></script>



    <footer class="site-footer">
    <div class="wrapper">
        <p class="description">
             Copyright (c) 2016-2020 tboox.org 
        </p>
        <p class="contact">
            
            <a href="https://github.com/waruqi" title="GitHub"><i class="fa fa-github" aria-hidden="true"></i></a> 
             
            
            <a href="mailto:waruqi@gmail.com" title="email"><i class="fa fa-envelope-o" aria-hidden="true"></i></a> 
            
            
            <a href="https://twitter.com/waruqi" title="Twitter"><i class="fa fa-twitter" aria-hidden="true"></i></a> 
            
            <a href="/feed.xml" title="feed"><i class="fa fa-feed" aria-hidden="true"></i></a> 
        </p>
        <p class="power">
            <span>
                Site powered by <a href="https://jekyllrb.com/">Jekyll</a> & <a href="https://github.com/Gaohaoyang">HyG</a> & <a href="https://pages.github.com/">Github Pages</a>.
            </span>
        </p>
    </div>
</footer>

    <div class="back-to-top">
    <a href="#top" class="scroll">
        <i class="fa fa-arrow-up" aria-hidden="true"></i>
    </a>
</div>

    <script src=" /js/main.js " charset="utf-8"></script>
    <script src=" /js/scroll.min.js " charset="utf-8"></script>
  </body>

</html>
